package com.example.cpms.controller;

import com.example.cpms.entity.Building;
import com.example.cpms.entity.Warning;
import com.example.cpms.service.WarningService;
import com.example.cpms.utils.PageBean;
import com.example.cpms.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@Slf4j
@RestController
public class WarningController {
    @Autowired
    private WarningService warningService;


    /**
     * 分页查询
     * @param page
     * @param pageSize
     * @return
     */
    @GetMapping("/pole/warning/list")  //改用PageHelper插件
    public Result page(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10")Integer pageSize, String poleName,String poleNumber, Integer handelStatus){
        log.info("告警记录分页查询：{}，{},{}",page,pageSize,poleName,poleNumber,handelStatus);
        PageBean pageBean = warningService.page(page,pageSize,poleName,poleNumber,handelStatus);
        return Result.success(pageBean);
    }



    /**
     *根据id删除告警记录
     * @return
     */
    @DeleteMapping("/pole/warning/{id}")
    public Result delete(@PathVariable Integer id){
        log.info("根据id删除告警记录：{}",id);
        warningService.delete(id);
        return Result.success();
    }



}
